"""
The "page require is a variable name.
Get the variable value from the user profile, but
remove any <br> breaks from the value.
"""


from whiff.middleware import misc
from whiff import whiffenv
from whiff import gateway

class getClean(misc.utility):
    def __init__(self, page):
        self.page = page
    def __call__(self, env, start_response):
        variableName = self.param_value(self.page, env)
        resourcePath = ["profile", "item", variableName]
        variableValue = gateway.getResource(env, resourcePath)
        if not variableValue:
            variableValue = ""
        variableValue = variableValue.replace("<br>", "")
        return self.deliver_page(variableValue, env, start_response)

__middleware__ = getClean
